@extends('../manage.layout')
@section('content')
    <!-- Content Header (Page header) -->
    <section class="content-header">
        <h1>
            印刷供应商列表
            <small></small>
        </h1>
        <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> Level</a></li>
            <li class="active">Here</li>
        </ol>
    </section>
    <!-- Main content -->
    <section class="content">
        <div class="row">
            <div class="col-md-12">
                {{--<form action="/manage/artibatcserc/" method="post" id="form">{{ csrf_field() }}--}}
                <!-- general form elements -->
                <div class="box box-primary">
                    <div class="box-header with-border">
                        {{--<a href="javascript:batchdelSub()"><span class="btn btn-danger">批量删除</span></a> <a href="/manage/article/create" type="submit" class="btn btn-success"><i class="fa fa-pencil"></i> 添加文章</a>--}}
                    </div>
                    <!-- table start -->
                    <div class="row">

                        <div class="col-xs-12">
                                <div class="box-header">
                                    <h3 class="box-title">供应商信息</h3>
                                    <div class="box-tools">
                                        <form action="/manage/client" method="post">
                                            <div class="input-group input-group-sm" style="width: 250px;">
                                                {{csrf_field()}}
                                                <input type="text" name="search" class="form-control pull-right" placeholder="根据公司名称搜索">

                                                <div class="input-group-btn">
                                                    <button type="submit" class="btn btn-default" onclick="search()"><i class="fa fa-search"></i></button>
                                                </div>
                                            </div>
                                        </form>
                                    </div>
                                    {{--<div class="box-tools">--}}
                                        {{--<div class="input-group input-group-sm" style="width: 150px;">--}}
                                            {{--<select class="form-control pull-right"  name="category" id="category" style="position:absolute; right:410px;">--}}
                                                {{--<option value="">请选择</option>--}}
                                                {{--@foreach($categorys as $category)--}}
                                                    {{--<option value="{{ $category->id }}">{{ $category->name }}</option>--}}
                                                {{--@endforeach--}}
                                            {{--</select>--}}
                                            {{--<input type="text" name="create_time" class="form-control pull-right" id="reservation" style="position:absolute; right: 296px;" value="">--}}
                                            {{--<input type="text" name="keyword" class="form-control pull-right" placeholder="关键词" style="position:absolute; right:148px">--}}
                                            {{--<input type="text" name="table_search" class="form-control pull-right" placeholder="标题">--}}

                                            {{--<div class="input-group-btn">--}}
                                                {{--<button type="submit" class="btn btn-default"><i class="fa fa-search"></i></button>--}}
                                            {{--</div>--}}
                                        {{--</div>--}}
                                    {{--</div>--}}
                                </div>
                                <!-- /.box-header -->
                                <div class="box-body table-responsive no-padding">
                                    <table class="table table-hover" id="table">
                                        <tr>
                                            {{--<th><input type="checkbox" value="" onclick="selectAll(this)"></th>--}}
                                            <th>ID(权重)</th>
                                            <th>公司名称</th>
                                            <th>联系人</th>
                                            <th>联系电话</th>
                                            <th>详细地址</th>
                                            <th>省</th>
                                            <th>市</th>
                                            <th>区县</th>
                                            {{--<th>经营范围</th>--}}
                                            <th>备注</th>
                                            <th>状态</th>
                                            <th>操作</th>
                                        </tr>
                                        @foreach($client as $v)
                                            <tr>
                                                <td>{{$v->id}}({{$v->rank}})</td>
                                                <td>{{$v->name}}</td>
                                                <td>{{$v->linkman}}</td>
                                                <td>{{$v->phone}}</td>
                                                <td>{{$v->address}}</td>
                                                <td>{{$v->province}}</td>
                                                <td>{{$v->city}}</td>
                                                <td>{{$v->county}}</td>
                                                {{--<td>{{$v->scope}}</td>--}}
                                                <td>{{$v->remark}}</td>
                                                <td>
                                                    @if($v->status == 0)
                                                        <label class="btn btn-warning btn-xs">禁用</label>
                                                    @else
                                                        <label class="btn btn-success btn-xs">启用</label>
                                                    @endif
                                                </td>
                                                <td>
                                                    @if($v->status == 1)
                                                        <a id="setStatus" class="btn btn-warning btn-xs" href="javascript:setStatus('{{ $v->id }}',0)">禁用<a>
                                                    @elseif($v->status == 0)
                                                        <a id="setStatus" class="btn btn-success btn-xs" href="javascript:setStatus('{{ $v->id }}',1)">启用<a>
                                                    @endif
                                                    <a href="/manage/client/edit/{{ $v->id }}"><span class="label label-primary">更改</span></a>
                                                </td>
                                            </tr>
                                        @endforeach
                                    </table>
                                </div>
                                <!-- /.box-body -->
                            <!-- /.box -->
                        </div>

                    </div>
                    <!-- /.table -->
                    <div style="text-align: center">{{ $client->links() }}</div>

                </div>
            </div>
        </div>
    </section>
    <!-- /.content -->
@endsection
@section('script')
    <script>
        //禁用
        function setStatus(id,status) {
            $.ajax({
                url: '/manage/client/setStatus',
                type: "GET",
                data:{id:id,status:status},
                dataType: "json",
                success: function(res) {
                    console.log(res);
                    if(res.code == 100) {
                        window.location.href=window.location.href;
                        if($('#setDisabled').html() == '禁用'){
                            $('#setDisabled').addClass('btn btn-success btn-xs');
                        }else{
                            $('#setDisabled').addClass('btn btn-danger btn-xs');
                        }
                        layer.msg(res.msg, {time:1500, icon:6})
                    }
                    else {
                        layer.msg(res.msg, {time:1500, icon:5})
                    }
                }
            });
        }
    </script>
    <script type="text/javascript">
        $('#reservation').daterangepicker();
    </script>
@endsection